<template>
  <div>
    <!-- <el-button @click="goHome"> 登录</el-button> -->
    <el-button @click="showNotification"> diloag</el-button>
    <span>{{ myName }}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      myName: "",
    };
  },
  methods: {
    // goHome() {
    //   this.myName = process.env.VUE_APP_NAME;
    //   console.log(this.myName);
    // },
    // 在Vue组件中调用通知
    showNotification() {
      if (Notification.permission === "granted") {
        new Notification("Hello from Vue2!", {
          body: "This is a notification from Vue2.",
          icon: "path_to_icon.png",
        });
      } else if (Notification.permission !== "denied") {
        Notification.requestPermission().then((permission) => {
          if (permission === "granted") {
            new Notification("Hello from Vue2!", {
              body: "This is a notification from Vue2.",
              icon: "path_to_icon.png",
            });
          }
        });
      }
    },
  },
};
</script>

<style></style>
